package main;

/**
 * @author Xu,
 * @data 2020/11/24，
 * @time 12:29
 * 单线程处理
 */
public class SingleThread {
    private double sf = 1;
    private double pi = 0;
    private double item = 1.0;
    private double den = 1.0;
    private final double MAX = 1e-10;
    public SingleThread(){
        long start = System.currentTimeMillis();
        while(Math.abs(item) >= MAX){
            pi += item;
            den += 2;
            sf = -sf;
            item = sf/den;
        }
        pi = 4 * pi;
        //System.out.println("pi的值为: "+ pi);
        long end = System.currentTimeMillis();
        System.out.println("runtime: " + (end - start)/1000.0+"s");
    }
}
